//
//  NRWCenterCell.m
//  Finance
//
//  Created by 邢毅 on 2018/7/31.
//  Copyright © 2018年 com.anpxd. All rights reserved.
//

#import "NRWCenterCell.h"

@implementation NRWCenterCell
{
	UIImageView *_iconImageView;
	UILabel *_titleLabel;
}

- (instancetype)initWithFrame:(CGRect)frame
{
	self = [super initWithFrame:frame];
	if (self) {
		
		_iconImageView = [[UIImageView alloc] init];
		
		_titleLabel = [[UILabel alloc] init];
		_titleLabel.textColor = getColor(@"#666666");
		_titleLabel.font = getThemeFont(16);
		_titleLabel.textAlignment = NSTextAlignmentCenter;
		
		[self.contentView addSubview:_iconImageView];
		[self.contentView addSubview:_titleLabel];
		
		self.contentView.backgroundColor = _titleLabel.backgroundColor = _iconImageView.backgroundColor = [UIColor whiteColor];
		self.contentView.opaque = _titleLabel.opaque = _iconImageView.opaque = YES;
		
		[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
			make.top.equalTo(self.contentView.mas_centerY).offset(5);
			make.left.right.equalTo(self.contentView);
		}];
		
		[_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
			make.bottom.equalTo(self.contentView.mas_centerY).offset(-5);
			make.centerX.equalTo(self.contentView.mas_centerX);
			
		}];
	}
	return self;
}

- (void)setImageName:(NSString *)imageName {
	
	_imageName = imageName;
	
	_iconImageView.image = getImage(imageName);
}

- (void)setTitleString:(NSString *)titleString {
	
	_titleString = titleString;
	
	_titleLabel.text = _titleString;
}

@end
